package com.example.mobile2032021606163crw0413;

import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView tvMainTitle;
    private Button btnMainDenglu;
    private Button btnMainTuichu;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        btnMainDenglu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new AlertDialog.Builder(MainActivity.this)
                        .setTitle("QQ登录")
                        .setMessage("是否确认登录")
                        .setPositiveButton("确认", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                new AlertDialog.Builder(MainActivity.this)
                                        .setTitle("QQ官方提示")
                                        .setMessage("您的QQ已在手机客户端登录")
                                        .setPositiveButton("好的哦", new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int which) {
                                                Toast.makeText(MainActivity.this,"登录成功",Toast.LENGTH_SHORT).show();
                                            }
                                        })
                                        .create()
                                        .show();

                            }
                        })
                        .create()
                        .show();
            }
        });
        btnMainTuichu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new AlertDialog.Builder(MainActivity.this)
                        .setTitle("QQ登录")
                        .setMessage("是否确认退出")
                        .setNegativeButton("退出", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                Toast.makeText(MainActivity.this,"退出成功",Toast.LENGTH_SHORT).show();
                                dialog.dismiss();
                                MainActivity.this.finish();
                            }
                        })
                        .create()
                        .show();

            }
        });
    }

    private void initView() {
        tvMainTitle = (TextView) findViewById(R.id.tv_main_title);
        btnMainDenglu = (Button) findViewById(R.id.btn_main_denglu);
        btnMainTuichu = (Button) findViewById(R.id.btn_main_tuichu);
    }
}